/*****************************************************************
**                                                             	**
**  Copyright (C) 2004 Amlogic,Inc.                            	**
**  All rights reserved                                        	**
**        Filename : WinPicInfoBar.c /Project:AVOS		       **
**        Revision : 1.0                                       	**
**                                                             	**
*****************************************************************/
#include "../menu.h"
#include "WinPicInfoBarEvent.h"
#include "./win/NetmenuSetupEvent.h"
extern INT32S WinPicInfoBarOnShow(PHWND hwnd, INT32S lpParam);
extern INT32S MiniBarOnShow(PHWND hwnd, INT32S lpParam);
void SetWinPicInfoBar_720PPalette(void)
{
    YUVENTRY mask_para[4] = {0,110,4095,4095};
    AWSetAlphaMask(0,4, mask_para);
    YUVENTRY palette_para[16] = {0x8000 | 15208,0x8000 | 16216,0x8000 | 17880,0x8000 | 16392,16280,16184,16088,16040,16024,15880,15208,15720,15016,15064,15304,15144};
    AWSetPalette(0,16, palette_para);
    return ;
}
INT32S WinPicInfoBar_720PMsgProc(PHWND hwnd, INT32U msg_type, INT32S lpParam)
{
	   switch( msg_type){
	   	case WM_CREATE:
	   		//SetWinPicInfoBarPalette();
	   		break;
        case WM_SHOWWINDOW:
            return WinPicInfoBarOnShow(hwnd, lpParam) ;
       default:
            return 0 ;
         }
    return 0 ;
  }
void SetWinPicInfoBar_720PPos(HWND* pControl, INT8U CurOsdSize)
{
            RECT StandardWindowRect = {0,0,1280,720};
            pControl->winrect = StandardWindowRect;
            CREATEWINDOWPARAM StandardWindowPara = {2,{{240,640,800,32},
            {1000,60,120,32},
            {0,0,0,0},
            {0,0,0,0}},
            {PF_PALETTE_256,PF_PALETTE_256,0,0},SetWinPicInfoBar_720PPalette};
            AWSendMessage(pControl, WM_WINDOW_RESET_DRAW_AREA, (INT32S)&StandardWindowPara);
    return;
}

HWND *CreateControlWinPicInfoBar_720P(HWND* pParent,INT8U CurOsdSize)
{
    		HWND* pNewControl;
           	CREATEWINDOWPARAM window_para= {2,{{240,640,800,32},
            {1000,60,120,32},
            {0,0,0,0},
            {0,0,0,0}},
           {PF_PALETTE_256,PF_PALETTE_256,0,0},SetWinPicInfoBarPalette};
    		pNewControl = AWCreateWinControl("TWindow","WinPicInfoBar_720P",WS_OVERLAPPEDWINDOW,
		         0,0,0,0,NULL, (INT32S)&window_para,WinPicInfoBar_720PMsgProc) ;
          	pNewControl->win_id = 0 ;
            return pNewControl;
}

void SetPicInfoBar_720PPos(HWND* pControl, INT8U CurOsdSize)
{
    int iLoop;
            pControl->winrect.top = pControl->parent->winrect.top + 640;
            pControl->winrect.left = pControl->parent->winrect.left + 240;
            pControl->winrect.width = 800;
            pControl->winrect.height = 32;
            pControl->draw_info_num = 9;
            RECT StandardDrawRect[9] = {
            {pControl->winrect.left + 0,pControl->winrect.top + 0,800,32},
            {pControl->winrect.left + 120-32,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 215-32,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 310-32,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 405-32,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 500-32,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 595-32,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 625,pControl->winrect.top + 0,170,32},
            {pControl->winrect.left + 630,pControl->winrect.top + 5,160,27}
             };
            for(iLoop=0; iLoop < 9; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &StandardDrawRect[iLoop], sizeof(RECT));
    return;
}

	
INT32S PicInfoBar_720PMsgProc(PHWND hwnd, INT32U msg_type, INT32S lpParam)
{
    switch( msg_type){
    	
        case WM_SHOWWINDOW:
            return PicInfoBarOnShow(hwnd, lpParam) ;
        case WM_KEYDOWN:
            return PicInfoBarOnKeyPress(hwnd, lpParam) ;
        default:
            return PicInfoBarOnOtherEvent(hwnd, msg_type, lpParam) ;
    }
    return 0 ;
}
INT32S MiniBar_720PMsgProc(PHWND hwnd,INT32U msg_type,INT32S lpParam)
{
    switch( msg_type){
    	
        case WM_KEYDOWN:
            return MiniBarOnKeyPress(hwnd, lpParam) ;
        default:
            return 0;
    }
    return 0 ;
}
HWND *CreateControlPicInfoBar_720P(HWND *pParent,INT8U CurOsdSize)
{
    //Create Control -- PicInfoBar
    HWND *pNewControl;
    pNewControl = AWCreateWinControl("TControl","PicInfoBar_720P",(WS_CHILDWINDOW | WS_CHILDWINDOW),
		         240,640,800,32,pParent,0,PicInfoBar_720PMsgProc) ;
    pNewControl->win_id = 2 ;
    pNewControl->draw_info_num = 9;
    pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
    DRAWINFO DrawDatas[9] = {
        {0,0,0,0,(INT32U)ICON_INFOBAR_STATUS512,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PREV_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PLAY_FOCUS,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_NEXT_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_ROTATE_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_STOP_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_ZOOM_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_INFOBAR_STATUS140,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)0,DT_STRING_DATA}
        };
    memcpy(pNewControl->draw_info, DrawDatas, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            return pNewControl;
}

void SetMiniBar_720PPos(HWND* pControl, INT8U CurOsdSize)
{
    int iLoop;
            pControl->winrect.top = pControl->parent->winrect.top + 60;
            pControl->winrect.left = pControl->parent->winrect.left + 1000;
            pControl->winrect.width = 120;
            pControl->winrect.height = 32;
            pControl->draw_info_num = 4;
            RECT StandardDrawRect[4] = {
            {pControl->winrect.left + 0,pControl->winrect.top + 0,120,32},
            {pControl->winrect.left + 4,pControl->winrect.top + 0,32,32},
            {pControl->winrect.left + 36,pControl->winrect.top + 0,16,32},
            {pControl->winrect.left + 54,pControl->winrect.top + 0,32,32},
            };
            for(iLoop=0; iLoop < 4; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &StandardDrawRect[iLoop], sizeof(RECT));
    return;
}

HWND *CreateControlMiniBar_720P(HWND *pParent)
{
    //Create Control -- WinPicFileInfo
    HWND *pNewControl;
     pNewControl = AWCreateWinControl("TControl","MiniBar_720P",(WS_CHILDWINDOW | 	WS_CHILDWINDOW),
		         1000,60,120,32,pParent,0,MiniBar_720PMsgProc) ;
    pNewControl->win_id = 4 ;
    pNewControl->draw_info_num = 4;
    pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
    DRAWINFO DrawDatas[4] = {
       // {0,0,0,0,(INT32U)ICON_INFOBAR_STATUS1,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA}};
    memcpy(pNewControl->draw_info, DrawDatas, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
            return pNewControl;
}

HWND* CreateMenuWinPicInfoBar_720P(void)
{
    HWND *pNewControl ;
    TWINDOWS *pWin;
    HWND *pWinPicInfoBar = CreateControlWinPicInfoBar_720P(NULL,CurrentOsdSize);
    SetWinPicInfoBar_720PPos(pWinPicInfoBar,CurrentOsdSize);

    pNewControl= CreateControlPicInfoBar_720P(pWinPicInfoBar,CurrentOsdSize);
    SetPicInfoBar_720PPos(pNewControl,CurrentOsdSize);

    pNewControl= CreateControlMiniBar_720P(pWinPicInfoBar);
    SetMiniBar_720PPos(pNewControl,CurrentOsdSize);

    pWin = (TWINDOWS *)pWinPicInfoBar;
    pWin->pFocusControl = AWFindWinCtrlByName("PicInfoBar_720P");
    return pWinPicInfoBar;
}

void WinResetWinPicInfoBar_720PControlsPos(HWND *pControl, INT8U CurOsdSize)
{
    switch(pControl->win_id){
        case 0://WinPicInfoBar
            SetWinPicInfoBar_720PPos(pControl,CurOsdSize) ;
            break ;
        case 2://PicInfoBar
            SetPicInfoBar_720PPos(pControl,CurOsdSize) ;
            break ;
        case 4://MiniBar
            SetMiniBar_720PPos(pControl,CurOsdSize) ;
            break ;
    }//end of switch
}
void WinResetWinPicInfoBar_720PPos(HWND *pControl, INT8U CurOsdSize)
{
    HWND *pChildControl;
    if(pControl == NULL)
        pControl = AWFindWinCtrlByName("WinPicInfoBar_720P");
    if(pControl == NULL) return ;

    WinResetWinPicInfoBar_720PControlsPos(pControl, CurOsdSize) ;
    pChildControl = pControl->children ;
    while(pChildControl != NULL){
    	WinResetWinPicInfoBar_720PPos(pChildControl, CurOsdSize) ;
    	pChildControl = pChildControl->siblings ;
	}
	return ;
}

